<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function whoWins(arr, row, line, value) {
            let yTopDistance = undefined
            //找y轴上方相邻且相同的最远距离
            if (row === 0) {
                yTopDistance = 0
            } else {
                for (let i = row; i > -1; i--) {
                    // debugger
                    yTopDistance = row - i -1
                    if (arr[i][line] !== value) {
                        break
                    }
                }
            }
            console.log(yTopDistance)
        }
        var arr = [
                    [0],
                    [0],
                    [2],
                    [2],
                    [2],
                    [2]
                ]
    </script>
</body>

</html>